import 'dart:convert' show json;

T asT<T>(dynamic value) {
  if (value is T) {
    return value;
  }

  return null;
}

class InspirationStyleBean {
  InspirationStyleBean({
    this.code,
    this.data,
  });

  factory InspirationStyleBean.fromJson(Map<String, dynamic> jsonRes) =>
      jsonRes == null
          ? null
          : InspirationStyleBean(
        code: asT<int>(jsonRes['code']),
        data: Data.fromJson(asT<Map<String, dynamic>>(jsonRes['data'])),
      );

  int code;
  Data data;

  Map<String, dynamic> toJson() => <String, dynamic>{
    'code': code,
    'data': data,
  };
  @override
  String toString() {
    return json.encode(this);
  }
}

class Data {
  Data({
    this.results,
  });

  factory Data.fromJson(Map<String, dynamic> jsonRes) {
    if (jsonRes == null) {
      return null;
    }

    final List<Style> results = jsonRes['results'] is List ? <Style>[] : null;
    if (results != null) {
      for (final dynamic item in jsonRes['results']) {
        if (item != null) {
          results.add(Style.fromJson(asT<Map<String, dynamic>>(item)));
        }
      }
    }
    return Data(
      results: results,
    );
  }

  List<Style> results;

  Map<String, dynamic> toJson() => <String, dynamic>{
    'results': results,
  };
  @override
  String toString() {
    return json.encode(this);
  }
}

class Style {
  Style({
    this.id,
    this.name,
  });

  factory Style.fromJson(Map<String, dynamic> jsonRes) => jsonRes == null
      ? null
      : Style(
    id: asT<int>(jsonRes['id']),
    name: asT<String>(jsonRes['name']),
  );

  int id;
  String name;

  Map<String, dynamic> toJson() => <String, dynamic>{
    'id': id,
    'name': name,
  };
  @override
  String toString() {
    return json.encode(this);
  }
}
